<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>ISA</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <h:outputStylesheet library="images" name="style.css" />
        <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
    </h:head>
    <h:body>
        <p:growl id="growl" showDetail="true" life="3000" />
        <div id="header">
            <!-- LOGOWANIE -->
            <c:set var="loggedVar" value="display: none;"/>
            <c:set var="unLoggedVar" value="display: none;"/>
            <c:if test="#{login.user.permition == 0}">
                <c:set var="unLoggedVar" value="display: block;"/>
            </c:if>
            <c:if test="#{login.user.permition != 0}">
                <c:set var="loggedVar" value="display: block;"/>
            </c:if>

            <h:panelGroup style="#{loggedVar}" id="logged">
                <h:form>Witaj <b>#{login.user.login}</b> (<p:commandLink actionListener="#{login.doLogout}" update="growl,login,pass" oncomplete="handleLogoutRequest();" value="Wyloguj" title="wyloguj" />)</h:form>
            </h:panelGroup>
            <h:panelGroup style="#{unLoggedVar}" id="unlogged">
                Witaj <b>nieznajomy</b> (<h:outputLink value="#" onclick="loginDialog.show();" title="login">Zaloguj się</h:outputLink>)
            </h:panelGroup>

            <p:dialog id="loginDialog" header="Login" widgetVar="loginDialog">  
                <h:form>
                    <h:panelGrid columns="2" cellpadding="5">  
                        <h:outputLabel for="login" value="Login: *" />  
                        <p:inputText value="#{login.login}"   
                                     id="login" required="true" label="Login" />  
                        <h:outputLabel for="pass" value="Hasło * " />
                        <h:inputSecret value="#{login.pass}" styleClass="ui-inputfield ui-password ui-widget ui-state-default ui-corner-all"   
                                       id="pass" required="true" label="Hasło" />
                        <p:commandButton value="Zaloguj" update="growl,logged"
                                         actionListener="#{login.doLogin}"   
                                         oncomplete="handleLoginRequest(xhr, status, args)"/>  
                    </h:panelGrid>  
                </h:form>  
            </p:dialog>
            <script type="text/javascript">  
                function handleLoginRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.loggedIn) {  
                        jQuery('#loginDialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        loginDialog.hide();  
                        jQuery('#unlogged').hide();
                        jQuery('#logged').show(); 
                    }  
                }
                function handleLogoutRequest() {
                    jQuery('#unlogged').show();
                    jQuery('#logged').hide(); 
                }
            </script>  
            <!-- KONIEC LOGOWANIA -->
        </div>
        <div id="header2">
            <h:outputLink value="/ISA/view/dashboard.xhtml">
                <img class="logo" src="resources/images/logo-header.png" alt="Logo"/>
            </h:outputLink>
        </div>
        <div id="menu">
            <ul class="menu">
                <ui:insert name="menuServerWork">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Praca serwera <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/dashboard.xhtml">Podstawowe informacje</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/requestList.xhtml">Aktywne zapytania do serwera</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/WPList.xhtml">Procesy robocze</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
                <ui:insert name="menuSites">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Strony <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/sitesList.xhtml">Lista</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/sitesAdd.xhtml">Dodaj</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
                <ui:insert name="menuApps">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Aplikacje <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/applicationsList.xhtml">Lista</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/applicationsAdd.xhtml">Dodaj</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
                <ui:insert name="menuAppPools">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Grupy aplikacji <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/appPoolsList.xhtml">Lista</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/appPoolsAdd.xhtml">Dodaj</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
                <ui:insert name="menuVDirs">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Wirtualne foldery <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/vDirList.xhtml">Lista</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/vDirAdd.xhtml">Dodaj</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
                <ui:insert name="menuModules">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Moduły <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/modulesList.xhtml">Lista</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/modulesAdd.xhtml">Dodaj</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/modulesInstall.xhtml">Instaluj</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
                <ui:insert name="menuBackups">
                    <li><a href="#" onClick="menuUpAndDown(this);">
                            Backup konfiguracji <img src="resources/images/dyn_up.gif" alt="Pokaż" /></a>
                        <ul class="submenu" style="display: none;">
                            <li><h:outputLink value="/ISA/view/backupList.xhtml">Lista</h:outputLink></li>
                            <li><h:outputLink value="/ISA/view/backupAdd.xhtml">Dodaj</h:outputLink></li>
                        </ul>
                    </li>
                </ui:insert>
            </ul>
            <div id="menu_down"></div>
            <script>
                function menuUpAndDown(element){
                    $ = jQuery;
                    menuHandler = $(element).parent();
                    menuHandler.children('ul').toggle('normal');
                    //podmiana obrazka
                    imageHandler = menuHandler.children('a').children('img');
                    if(imageHandler.attr('src') == 'resources/images/dyn_up.gif'){
                        imageHandler.attr('src', 'resources/images/dyn_down.gif');
                        imageHandler.attr('alt', 'Ukryj');
                    } else {
                        imageHandler.attr('src', 'resources/images/dyn_up.gif');
                        imageHandler.attr('alt', 'Pokaż');
                    }
                }
            </script>

        </div>
        <div id="content">
            <ui:insert name="content">
                Podana strona jest szablonem!
            </ui:insert>
        </div>
        <div id="footer">Copyright © 2011 - Paweł Napieracz i Agata Wiatrowska | 
            <a href="http://www.visualpharm.com">Darmowe ikonki</a></div>
    </h:body>
</html>